<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
<head>
<title>信息管理系统</title>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.7.1.js"></script>
<link href="${pageContext.request.contextPath}/css/authority/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/css/authority/backstage_css.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/css/authority/common_style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/authority/commonAll.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-1.4.4.min.js"></script>
<script src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/artDialog/artDialog.js?skin=default"></script>
<script type="text/javascript">
	$(document).ready(function() {
		/*
		 * 提交
		 */
		$("#submitbutton").click(function() {
			if(validateForm()){
				checkFyFhSubmit();
			}
		});
		
		/*
		 * 取消
		 */
		$("#cancelbutton").click(function() {
			/**  关闭弹出iframe  **/
			window.parent.$.fancybox.close();
		});
		
		var result = 'null';
		if(result =='success'){
			/**  关闭弹出iframe  **/
			window.parent.$.fancybox.close();
		}
	});
	
	/** 检测房源房号是否存在  **/
	function checkFyFh(){
		// 分别获取小区编号、栋号、层号、房号
		var fyID = $('#fyID').val();
		var fyXqCode = $("#fyXq").val();
		var fyDh = $("#fyDh").val();
		var fyCh = $("#fyCh").val();	
		var fyFh = $("#fyFh").val();
		if(fyXqCode!="" && fyDh!="" && fyCh!="" && fyFh!=""){
			// 给房屋坐落地址赋值
			$("#fyZldz").val($('#fyDh option:selected').text() + fyCh + "-" + fyFh);
			// 异步判断该房室是否存在，如果已存在，给用户已提示哦
			$.ajax({
				type:"POST",
				url:"checkFyFhIsExists.action",
				data:{"fangyuanEntity.fyID":fyID,"fangyuanEntity.fyXqCode":fyXqCode, "fangyuanEntity.fyDhCode":fyDh, "fangyuanEntity.fyCh":fyCh, "fangyuanEntity.fyFh":fyFh},
				dataType : "text",
				success:function(data){
// 					alert(data);
					// 如果返回数据不为空，更改“房源信息”
					if(data=="1"){
						 art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'该房室在系统中已经存在哦，\n请维护其他房室数据', ok:true,});
						 $("#fyFh").css("background", "#EEE");
						 $("#fyFh").focus();
						 return false;
					}
				}
			});
		}
	}
	
	/** 检测房源房号是否存在并提交form  **/
	function checkFyFhSubmit(){
		// 分别获取小区编号、栋号、层号、房号
		var fyID = $('#fyID').val();
		var fyXqCode = $("#fyXq").val();
		var fyDh = $("#fyDh").val();
		var fyCh = $("#fyCh").val();	
		var fyFh = $("#fyFh").val();
		if(fyXqCode!="" && fyDh!="" && fyCh!="" && fyFh!=""){
			// 给房屋坐落地址赋值
			$("#fyZldz").val($('#fyDh option:selected').text()  + fyCh + "-" + fyFh);
			// 异步判断该房室是否存在，如果已存在，给用户已提示哦
			$.ajax({
				type:"POST",
				url:"checkFyFhIsExists.action",
				data:{"fangyuanEntity.fyID":fyID,"fangyuanEntity.fyXqCode":fyXqCode, "fangyuanEntity.fyDhCode":fyDh, "fangyuanEntity.fyCh":fyCh, "fangyuanEntity.fyFh":fyFh},
				dataType : "text",
				success:function(data){
// 					alert(data);
					// 如果返回数据不为空，更改“房源信息”
					if(data=="1"){
						 art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'该房室在系统中已经存在哦，\n请维护其他房室数据', ok:true,});
						 $("#fyFh").css("background", "#EEE");
						 $("#fyFh").focus();
						 return false;
					}else{
						$("#submitForm").attr("action", "/xngzf/archives/saveOrUpdateFangyuan.action").submit();
					}
				}
			});
		}
		return true;
	}
	
	/** 表单验证  **/
	function validateForm(){
		if($("#stuNumber").val()==""){
			art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请填写学号', ok:true,});
			return false;
		}
		if($("#name").val()==""){
			art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请填写名字', ok:true,});
			return false;
		}
		if($("#password").val()==""){
			art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请填写密码', ok:true,});
			return false;
		}
		if($("#repassword").val()==""){
			art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请确认密码', ok:true,});
			return false;
		}
		if($("#email").val()==""){
			art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请填写邮箱', ok:true,});
			return false;
		}
		if($("#phoneNum").val()==""){
			art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请填写号码', ok:true,});
			return false;
		}
		return true;
	}
</script>
</head>
<body style="text-align: center">
<%--<s:debug></s:debug>--%>
<form id="submitForm" name="submitForm" action="/equipmentDetail/addEquipment.do" method="post">
	<input type="hidden" name="fyID" value="14458625716623" id="fyID"/>
    <input type="hidden" name="isBS" value="isBS">
	<div id="container">
		<div id="nav_links">
			当前位置：基础数据&nbsp;>&nbsp;<span style="color: #1A5CC6;">器材管理</span>
			<div id="page_close">
				<a href="javascript:parent.$.fancybox.close();">
					<img src="${pageContext.request.contextPath}/images/common/page_close.png" width="20" height="20" style="vertical-align: text-top;"/>
				</a>
			</div>
		</div>
		<div class="ui_content">
            <div>
                <label for="equipmentName">&nbsp;&nbsp;名&nbsp;&nbsp;&nbsp;&nbsp;字：</label>
                <input class="username" type="text" name="equipmentName" id="equipmentName" placeholder="请输入器材名字" required="required"/><br/>
            </div>
            <div>
                <label for="password">&nbsp;&nbsp;价&nbsp;&nbsp;&nbsp;&nbsp;格：</label>
                <input class="username" type="text" name="price" id="password" placeholder="请输入价格" required="required"/><br/>
            </div>
            <div style="margin-top: 15px;">
                <input type="submit" value="提交" class="button" style="width:80px;height: 30px"/>&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="reset" value="重置" class="button" id="reset" style="width:80px;height: 30px"/>
            </div>
		</div>
	</div>

</form>
<div style="height: 70px"></div>
<div style="display:none"><script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540' language='JavaScript' charset='gb2312'></script></div>
</body>
<script type="text/javascript">
    $().ready(function () {
       $("#selectRole").hover(function () {
           var roleId = $("#roleId").val();
           $.ajax({
               url:"bsIndex.do",
               data:roleId,
               type:"GET",
               success: function (data) {
                   var json = eval(data);
                for(var i= 0,len=json.length;i<len;i++){
                    $("#showRole").html("<li>"+json[i].name+"<input type='hidden' value='"+json[i].id+"'/><br/></li>");
                }
               }
           })
       });
    });
</script>
</html>